# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer: Will Sinatra <wpsinatra@gmail.com>
pkgname=libcbor
pkgver=0.11.0
pkgrel=1
pkgdesc="CBOR protocol implementation for C"
url="https://github.com/PJK/libcbor"
arch="all"
license="MIT"
makedepends="cmake samurai"
checkdepends="cmocka-dev"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/PJK/libcbor/archive/refs/tags/v$pkgver.tar.gz"
#rebuild: libfido2 fwupd

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DWITH_TESTS="$(want_check && echo ON || echo OFF)" \
		$CMAKE_CROSSOPTS .
	cmake --build build
}

check() {
	cd build
	ctest
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
c14aaa55c0c82e09b9eb2cc6847951d1bac8a081a247776c507d5450367da5717b1056bad09fb0f0178311de8754e8f89c060e0fc0f400fafdc42de441421e66  libcbor-0.11.0.tar.gz
"
